package com.ehome.user.Fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.ehome.user.Activity.Login.LoginActivity;
import com.ehome.user.Activity.SetActivity;
import com.ehome.user.R;
import com.ehome.user.Utils.PreferencesUtils;
import com.ehome.user.Utils.Tools;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by Administrator on 2018/3/6 0006.
 */

public class PersonFragment extends Fragment {

    private LinearLayout ll_me;
    private LinearLayout ll_login;

    @Bind(R.id.tv_phone)
    TextView tv_phone;


    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.tab_person_fragment, container, false);
        ButterKnife.bind(this, view);
        Button button= (Button) view.findViewById(R.id.button);
        ll_me = (LinearLayout) view.findViewById(R.id.ll_me);
        ll_login = (LinearLayout) view.findViewById(R.id.ll_login);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(getActivity(), LoginActivity.class));
            }
        });
        return view;
    }
    @Override
    public void onStart() {
        super.onStart();
        if(PreferencesUtils.getBoolean(getContext(),"tag",false)){
            ll_me.setVisibility(View.VISIBLE);
            ll_login.setVisibility(View.GONE);
            tv_phone.setText(Tools.settingphone(PreferencesUtils.getString(getContext(),"phone")));
        }else {
            ll_me.setVisibility(View.GONE);
            ll_login.setVisibility(View.VISIBLE);
        }
    }

    @OnClick({R.id.iv_set})
    public void onViewClicked(View view){
        switch (view.getId()){
            case R.id.iv_set:
                startActivity(new Intent(getActivity(), SetActivity.class));
                break;
        }
    }
}
